﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConfigCreate
{
    /// <summary>
    /// 设置控件权限
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class CreateRolePermissionConrolAttribute : Attribute
    {
        /// <summary>
        /// 设置控件权限
        /// </summary>
        /// <param name="role_name">角色名</param>
        /// <exception cref="ConfigException">角色名为空时报错</exception>
        public CreateRolePermissionConrolAttribute(string role_name)
        {
            if (string.IsNullOrEmpty(role_name))
                throw new ConfigException("角色名不能为空");
            RoleName = role_name;
        }

        /// <summary>
        /// 角色名
        /// </summary>
        public string RoleName { get; set; }
        /// <summary>
        /// 设置权限限制类型
        /// </summary>
        public RolePermissionType PermissionType { get; set; } = RolePermissionType.Invisible;
    }
}
